<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>博客添加</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>

    <script>
        function deleteBlog(id) {
            //给用户提示框
            if (confirm("确定要删除吗?")) {
                //确定就跳转到删除功能
                location.href = "${pageContext.request.contextPath}/UserBlog/deleteBlog?id=" + id + "&afterDelete=${requestScope.afterDelete}";
            }
        }
    </script>
</head>
<body>
<div class="container">
    <a class="btn btn-primary" href="${pageContext.request.contextPath}/UserBlog/${requestScope.back}">返回</a>
    <hr>

    <%--添加专栏专栏用的--%>
    <form action="${pageContext.request.contextPath}/Column/addColumn?uid=${requestScope.userBlog.uid}&id=${requestScope.userBlog.id}&prior=${requestScope.columnId}"
          method="post">
        <a href="${pageContext.request.contextPath}/UserBlog/userBlog?ccurrentPage=${requestScope.columnPageBean.currentPage-1}&crows=5&columnId=${requestScope.columnId}&uid=${requestScope.userBlog.uid}&id=${requestScope.userBlog.id}">Previous</a>
        <ul class="nav nav-tabs">
            <c:if test="${requestScope.columnPageBean.totalCount!=0}">
                <c:forEach items="${requestScope.columnPageBean.list}" var="column" varStatus="s">
                    <li role="presentation">
                        <input type="radio" name="addColumnId" value="${column.id}">
                        <a href="${pageContext.request.contextPath}/UserBlog/userBlog?columnId=${column.id}&uid=${requestScope.userBlog.uid}&id=${requestScope.userBlog.id}"> ${column.name}</a>
                    </li>
                </c:forEach>
            </c:if>

            <c:if test="${requestScope.columnPageBean.totalCount==0}">
                <li> 目前该专栏没有子专栏哦</li>
            </c:if>
        </ul>
        <a href="${pageContext.request.contextPath}/UserBlog/userBlog?ccurrentPage=${requestScope.columnPageBean.currentPage+1}&crows=5&columnId=${requestScope.columnId}&uid=${requestScope.userBlog.uid}&id=${requestScope.userBlog.id}">Next</a>
        <div class="form-group">
            <input type="text" class="form-control" name="addColumn" placeholder="没有想要的专栏?">
        </div>
        <br><input class="btn btn btn-primary" type="submit" value="YES">
        <a class="btn btn-primary"
           href="${pageContext.request.contextPath}/UserBlog/userBlog?uid=${requestScope.userBlog.uid}&id=${requestScope.userBlog.id}">返回</a>
    </form>

    <!-- 显示的信息框 -->
    <c:if test="${requestScope.update_msg!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${requestScope.update_msg}</strong>
        </div>
    </c:if>

    <%--用户博客的图片用--%>

    <p style="float:right;">
    <form method="post"
          action="${pageContext.request.contextPath}/UserBlog/addImg?bid=${requestScope.userBlog.id}&uid=${requestScope.userBlog.uid}"
          enctype="multipart/form-data">
        <div class="form-group">
            <label for="exampleInputFile">图片上传</label>
            <input type="file" id="exampleInputFile" name="imgFile">
            <button type="submit" class="btn btn-default">上传</button>
        </div>
    </form>
    </p>

    <form action="${pageContext.request.contextPath}/UserBlog/updateBlog?id=${requestScope.userBlog.id}&afterBack=${requestScope.afterBack}"
          method="post">
        <h3><small>标题</small></h3>
        <input type="text" class="form-control" name="title" value="${requestScope.userBlog.title}">
        <h3><small>文章</small></h3>
        <textarea class="form-control" rows="30" name="content">${requestScope.userBlog.content}</textarea>

        <div class="form-group" style="text-align: center;">
            <input class="btn btn btn-primary" type="submit" value="提交">
            <a class="btn btn-primary" href="javascript: deleteBlog(${requestScope.userBlog.id});">删除</a>
        </div>
    </form>

    <!-- 显示的信息框 -->
    <c:if test="${blogBean!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${blogBean} wo1www</strong>
        </div>
    </c:if>

</div>
</body>
</html>
